<
<%@ page language="java" contentType="text/html; charset=UTF-8"

         pageEncoding="UTF-8" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>人才管理系统登录</title>

    <script src="vue.js"></script>

    <style>
        body {
            background: url(img/elm.jpg)
        }

        div {
            height: 400px;
            width: 600px;
            opacity: 0.5;
            background-color: white;
            color: red;
            border: 2px solid #3333ff;
            margin: auto;
            margin-top: 100px;
        }

        input {
            height: 30px;
            width: 200px;
            margin-top: 10px;
        }

        #su {
            height: 30px;
            width: 100px;
        }

    </style>
</head>

<body>

<%

    String cw = (String) request.getAttribute("cw");

    String cw2 = (String) request.getAttribute("cw2");

%>
<div>
    <center><h1>欢迎登录</h1></center>
    <br>

    <form action="loginservlet" method="get" name="frmLogin">

        <center>账号:<input type="text" name="id" class="txtb" placeholder="账号"></center>
        <br>

        <center>密码:<input type="password" name="password" class="txtb" placeholder="密码"></center>
        <br>

        <center>

            <input id="su" type="submit" value="登录" onclick="validateLogin()">

        </center>
        <br>


        <center><a href="register.jsp">注册一个？</a></center>

    </form>
</div>
<%

    if (cw != null) {

%>

<script type="text/javascript">

    var m = "${requestScope.cw}";

    if (m == "登录失败") {

        alert('用户名或密码错误');

    }


</script>

<%

    }

%>

<%

    if (cw2 != null) {

%>

<script type="text/javascript">

    var m = "${requestScope.cw2}";

    if (m == "账号已存在") {

        alert('账号已存在');

    }


</script>

<%

    }

%>
<script language="javaScript">

    function validateLogin() {
        var sUserName = document.frmLogin.id.value;
        var sPassword = document.frmLogin.password.value;
        if (sUserName == "" || sPassword == "") {
            alert("用户名或密码不能为空！");
            return false;
        }
        if (sUserName.length() > 20) {
            alert("用户名不能超过20个字符！");
            return false;
        }
        if (sPassword.length() > 10) {
            alert("密码不能超过10位！");
            return false;
        }
    }
</script>
</body>

</html>

